<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/30
 * Time: 13:58
 */
namespace app\admin\model;

class ComplaintModel extends BaseModel
{
    protected $table = "xst_complaint";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];

	//投诉管理信息查询
    public function index()
    {
        return $this->order('createtime desc')->paginate(10,false,['query'=>request()->param()]);
    }
    public function getOneId($id)
    {
        return $this->where('id',$id)->find();
    }
    //回复建议添加
    public function edit()
    {
        $revert = request()->post('revert');//回复建议
        $id = request()->post('id');
        return $this->where('id',$id)->update([
            'revert'=>$revert,
            'updatetime'=>time()
        ]);
    }
    //投诉信息删除
    public function del()
    {
        $id = request()->post('id');
		$rs = $this->where('id',$id)->find();
		$arr = array_filter(explode(',',$rs['photo']));
		foreach($arr as $key=>$val){
			$photo=ROOT_PATH .$val;
            @unlink($photo);
		}
        return $this->where('id',$id)->delete();
    }
    //投诉信息多删
    public function dell()
    {
        $id = request()->post('id');
        $rs = $this->where('id','in',$id)->find();
		$arr = array_filter(explode(',',$rs['photo']));
		foreach($arr as $key=>$val){
			$photo=ROOT_PATH .$val;
            @unlink($photo);
		}
        return $this->where('id','in',$id)->delete();
    }
}